package com.boang;

import com.boang.po.Spu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/*
  @author: 13813
  @date: 2024/8/19 15:40
*/
@RestController
@RequestMapping("/redis")
public class RedisController {

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @RequestMapping("/set")
    public String set() {
        //String
        ValueOperations<String, Object> stringOperations = redisTemplate.opsForValue();
//        stringOperations.set("java_key", "zhangsan");

        Spu spu = new Spu(1, "华为P999");
        stringOperations.set("spu", spu);

        //hash
        HashOperations<String, Object, Object> hashOperations = redisTemplate.opsForHash();

        //list
        ListOperations<String, Object> listOperations = redisTemplate.opsForList();
        return "success";
    }
}
